package org.feng;

import lombok.extern.slf4j.Slf4j;
import org.feng.config.MysqlDatasourceProperties;
import org.feng.config.MysqlDatasourcePropertiesV2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;


/**
 * 本案例使用 Webflux Api 操作 Mysql 数据库
 *
 * @author Administrator
 */
@Slf4j
@EnableSwagger2
@EnableTransactionManagement
@EnableConfigurationProperties(value = {MysqlDatasourceProperties.class, MysqlDatasourcePropertiesV2.class})
@SpringBootApplication
public class WebfluxHelloMysqlDemoApplication {

    public static void main(String[] args) throws UnknownHostException {
        final ConfigurableApplicationContext applicationContext = SpringApplication.run(WebfluxHelloMysqlDemoApplication.class, args);
        Environment env = applicationContext.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \thttp://{}:{}\n\t" +
                        "Doc: \thttp://{}:{}/doc.html\n\t" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port")
        );
    }

}
